//
//  ITError.swift
//  ITNetLibrary
//
//  Created by ellzu gu on 2021/5/27.
//

import Foundation

open class EZError : Error {
    public var domain : String
    public let code : Int
    public let subError : EZError?
    public let message : String?
    
    public init(_ domain: String, _ code: Int, message: String? = nil, subError: EZError? = nil) {
        self.domain = domain;
        self.code = code;
        self.message = message;
        self.subError = subError;
    }
    
    public var description: String {
        if let subError = self.subError {
            return String(format: "Domain=%@ Code=%d message=%@ sub:\n %@", self.domain, self.code, self.message ?? "", subError.description)
        } else {
            return String(format: "Domain=%@ Code=%d message=%@", self.domain, self.code, self.message ?? "")
        }
    }
}

